import request from '@/utils/request'

export function getServers(data) {
  return request({
    url: '/api/cmdb/servers/',
    method: 'get',
    params: data
  })
}

export function createServer(data) {
  return request({
    url: '/api/cmdb/servers/',
    method: 'post',
    data
  })
}

export function updateServer(id, data) {
  return request({
    url: `/api/cmdb/servers/${id}/`,
    method: 'put',
    data
  })
}

// 获取server详情
export function getServer(id) {
  return request({
    url: `/api/cmdb/servers/${id}/`,
    method: 'get'
  })
}

// 删除server
export function deleteServer(id) {
  return request({
    url: `/api/cmdb/servers/${id}/`,
    method: 'delete'
  })
}

// 批量删除服务器
export function deleteServers(ids) {
  return request({
    url: '/api/cmdb/servers/multiple-delete/',
    method: 'delete',
    data: { 'ids': ids }
  })
}

// 更新腾讯云服务器
export function updateTencentServer() {
  return request({
    url: '/api/cmdb/tencent/servers/',
    method: 'get',
    timeout: 600000
  })
}
